<script setup lang="ts">
import type { Props, Emits } from './utils/types'
import APIUploadMaterial from '@/api/upload-material'

const $props = defineProps<Props>()

const $emit = defineEmits<Emits>()

watch($props, (newValue) => {
    if (newValue.code) {
        videoInfo(newValue.code)
    }
}, { immediate: true })

function videoInfo(code: string) {
    APIUploadMaterial.picInfo(code).then(({ data }) => {
        if (data.work_status != 0 && data.work_status != 3) {
            setTimeout(() => {
                videoInfo($props.code)
            }, 2000)
        } else if (data.work_status == 0) {
            $emit('on-success')
        }
    })
}


</script>

<template>
    <div class="transcoding-video">
        转码中···
    </div>
</template>

<style lang="scss" scoped>
.transcoding-video {
    width: 200px;
    height: 112px;
    border-radius: 5px;
    border: 1px solid #b1b1b1;
    text-align: center;
    line-height: 112px;
    user-select: none;
}
</style>
